#include<bits/stdc++.h>
using namespace std;
int T,n,m,L,V,ans;
int d[100005],v[100005],a[100005],p[100005];
int main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	scanf("%d",&T);
	while(T--){
		set<int>ss;
		ans=0;
		scanf("%d%d%d%d",&n,&m,&L,&V);
		for(int i=1;i<=n;i++)scanf("%d%d%d",&d[i],&v[i],&a[i]);
		for(int i=1;i<=m;i++)
			scanf("%d",&p[i]);
		for(int i=1;i<=n;i++){
			for(int j=1;j<=m;j++){
				if(p[j]-d[i]<0)continue;
				double vv=sqrt(v[i]*v[i]+2*a[i]*(p[j]-d[i]));
				if(vv>V){
					ss.insert(i);
					break;
				}
			}
		}
		int ans=int(ss.size()),ans1=0;
		printf("%d ",ans);
		for(int ii=0;ii<(1<<m);ii++){
			ss.clear();
			int cnt=0;
			for(int i=1;i<=n;i++){
				for(int j=1;j<=m;j++){
					if((ii>>(j-1))&1){
						if(p[j]-d[i]<0)continue;
						double vv=sqrt(v[i]*v[i]+2*a[i]*(p[j]-d[i]));
						if(vv>V){
							ss.insert(i);
							break;
						}
					}
				}
				
			}
			for(int j=0;j<m;j++)if(!((ii>>j)&1))cnt++;
			if(int(ss.size())==ans)
				ans1=max(ans1,cnt);
		}
		printf("%d\n",ans1);
	}
}


